


#include "user_common.h"

#include "smarttimer.h"





uint32_t common_get_ms_tick(void)
{
	return 0;
}
void common_delay_us(uint8_t us)
{

}
void common_delay_ms(uint32_t ms)
{

}
void common_printf(char *format, ...)
{


}
void common_1ms_int(void)
{

    stim_tick();
}




static void Swap(char *p1,char *p2,int width)
{
    for (int i=0; i<width; i++)
    {
        char tmp = *(p1+i);
        *(p1+i) = *(p2+i);
        *(p2+i) = tmp;
    }
}



int cmp_u8(const void *p1, const void *p2)
{
    return *(uint8_t*)p1 - *(uint8_t*)p2;
}

int cmp_u16(const void *p1, const void *p2)
{
    return *(uint16_t*)p1 - *(uint16_t*)p2;
}

int cmp_u32(const void *p1, const void *p2)
{
    return *(uint32_t*)p1 - *(uint32_t*)p2;
}



void bubble_sort(void *base, int num, int width,int (*cmp)(const void *e1, const void *e2))
{
    for (int i=0; i<num-1; i++)
    {
        for (int j=0; j<num-i-1; j++)
        {
            if ((cmp((char*)base+j*width,(char*)base+(j+1)*width)>0))
            {
                Swap((char*)base+j*width, (char*)base+(j+1)*width, width);                  //Swap为交换函数
            }
        }
    }
}

